package com.springboot.cloud.demos.ribbon.rest;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.demos.entity.form.UserForm;
import com.springboot.cloud.demos.entity.form.UserQueryForm;
import com.springboot.cloud.demos.entity.form.UserRequestEntity;
import com.springboot.cloud.demos.entity.param.FollowQueryParam;
import com.springboot.cloud.demos.entity.po.User;
import com.springboot.cloud.demos.ribbon.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
public class UserController {

    @Autowired
    private UserService userService;


    @PutMapping("/user")
    public Result query(@RequestBody User user) {
        return userService.update(user);
    }

    @PostMapping("/user")
    public Result<User> add(@RequestBody UserForm userForm) {
        return userService.add(userForm);
    }

    @GetMapping("/user/queryByMobile")
    public Result<User> queryByMobile(@RequestParam("mobile") String mobile) {
        return userService.queryByMobile(mobile);
    }

    @GetMapping("/user/{id}")
    public Result<User> getById(@PathVariable("id") String id) {
        return userService.getById(id);
    }

    @GetMapping(value = "/user/getStatistics")
    public Result getStatistics(@RequestParam("userId") String userId) {
        return userService.getStatistics(userId);
    }

    @PostMapping(value = "/user/nearBy")
    public Result<Page> nearBy(@RequestBody UserQueryForm param) {
        return userService.nearBy(param);
    }

    @PostMapping(value = "/user/recommend")
    public Result<Page> recommend(@RequestBody UserQueryForm param) {
        return userService.recommend(param);
    }

    @PostMapping(value = "/user/getFollowMe")
    public Result<Page> getFollowMe(@RequestBody UserQueryForm param) {
        return userService.getFollowMe(param);
    }

    @PostMapping(value = "/user/getMyFollow")
    public Result<Page> getMyFollow(@RequestBody UserQueryForm param) {
        return userService.getMyFollow(param);
    }
}
